function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no';
	win = window.open(mypage, myname, winprops);
	return win;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function TopDate() {

	var mydate=new Date()
	var year=mydate.getFullYear()
	if (year<2000)
	year="19"+year
	var day=mydate.getDay()
	var month=mydate.getMonth()
	var daym=mydate.getDate()
	if (daym<10)
	daym="0"+daym
	var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
	var montharray=new Array("Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sep.","Oct.","Nov.","Dec.")
document.write("<font face='arial, verdana'; color='#000000'; size='1' >"+montharray[month]+" "+daym+", "+year+"</font>")
}

function _CF_trim(text)
{
	pos=0;
	for(i=0; i < text.length; i++)
		if(text.charAt(i) == " ")
			pos = i + 1;
		else
			break;
	text = text.substr(pos,text.length - pos);
	pos = text.length;
	for(i = text.length - 1;i >= 0; i--)
		if(text.charAt(i) == " ")
			pos = i;
		else
			break;
	return text.substr(0,pos)
}

function _CF_onError(form_object, input_object, error_message)
{
	alert(error_message);
	input_object.focus();
  	return false;	
}

function _CF_hasValue(obj, obj_type)
{
    if (obj_type == "TEXT" || obj_type == "PASSWORD")
	{
		obj.value = _CF_trim(obj.value);
    	if (obj.value.length == 0) 
      		return false;
    	else 
      		return true;
    }
    else if (obj_type == "SELECT")
	{
        for (i=0; i < obj.length; i++)
    	{
			if (obj.options[i].selected && obj.options[i].value != "")
				return true;
		}
       	return false;	
	}
    else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{
		if (obj.checked)
			return true;
		else
       		return false;	
	}
    else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{
	    if (obj[0] == null) {
			if(obj.checked)	return true;			
			else return false;
	    } 		
   	    for (i=0; i < obj.length; i++)
    	{
			if (obj[i].checked)
				return true;
		}
       	return false;	
	}
}


function _CF_checknumber(object_value)
{
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;
    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

    //The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(object_value.charAt(0))
    //Was it a decimal?
	if (check_char == 1)
	    decimal = true;
	else if (check_char < 1)
		return false;
        
	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
			if (decimal)		// Second decimal.
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)	
				trailing_blank = true;
        // ignore leading blanks

		}
	        else if (trailing_blank)
			return false;
		else
			digits = true;
	}	
    //All tests passed, so...
    return true
}

function _CF_numberrange(object_value, min_value, max_value)
{
    // check minimum
    if (min_value != null)
	{
        if (object_value < min_value)
			return false;
	}
    // check maximum
    if (max_value != null)
	{
		if (object_value > max_value)
			return false;
	}
    //All tests passed, so...
    return true;
}

function _CF_checkinteger(object_value)
{
    //Returns true if value is a number or is NULL
    //otherwise returns false	
    if (object_value.length == 0)
        return true;
    //Returns true if value is an integer defined as
    //   having an optional leading + or -.
    //   otherwise containing only the characters 0-9.
	var decimal_format = ".";
	var check_char;
    //The first character can be + -  blank or a digit.
	check_char = object_value.indexOf(decimal_format)
    //Was it a decimal?
    if (check_char < 1)
		return _CF_checknumber(object_value);
    else
		return false;
}
function trim(s){
	var re=/^\s+/;
	s=s.replace(re,"");
	re=/\s+$/;
	s=s.replace(re,"");
	return s;
}
var days = [0,31,28,31,30,31,30,31,31,30,31,30,31];
function isDate(d, m, y){
	d = deleteFirstZero(d);
	m = deleteFirstZero(m);
	y = deleteFirstZero(y);
	b = isNativeNumber(d) && isNativeNumber(m) && isNativeNumber(y) && m>0 && m<13 && d>0 && y>0;
	if (b){
		b = (d<=days[m]) || (m==2 && d==29 && (y%4==0))
	}
	return b;
}
/**
* check date and return the right dates
* using: var ret=["","", ""]
* isDMYDate("12-12-2001")
*/
function isDMYDate(s){
	s = deleteSpaces(s);
	var re=/-/g;
	s = s.replace(re, "/");
	dmy=s.split("/");
	b = dmy.length==3
	if (b){
		b = isDate(dmy[0],dmy[1],dmy[2]);
	}
	return b;
}
/**
* check date and return the right dates
* using: var ret=["","",""]
* isMDYDate("12-12-2001")
*/
function isMDYDate(s){
	s = deleteSpaces(s);
	var re=/-/g;
	s = s.replace(re, "/");
	dmy=s.split("/");
	b = dmy.length==3
	if (b){
		b = isDate(dmy[1],dmy[0],dmy[2]);
	}
	return b;
}
function deleteFirstZero(s){
	s=""+s;
	var re=/^0+/;
	s=s.replace(re,"");
	return s;
}
function isNativeNumber(s){
	s = trim(s);
	var re=/[\D]/g;
	var r=s.replace(re,"");
	return r==s && r!="" ;
}
function deleteSpaces(s){
	var re=/\s/g;
	s=s.replace(re,"");
	return s;
}
function validPicture(object) {
	if (object.value != "") {
		var valFile1 = object.value;
		var listArrFile1 = valFile1.split(".");
		var lengthFile1 = listArrFile1.length;
		if (lengthFile1<=1) 
			return false;
		else if (listArrFile1[lengthFile1 - 1] != "gif" 
				 && listArrFile1[lengthFile1 - 1] != "GIF" 
				 && listArrFile1[lengthFile1 - 1] != "jpg" 
				 && listArrFile1[lengthFile1 - 1] != "JPG" 
				 && listArrFile1[lengthFile1 - 1] != "bmp" 
				 && listArrFile1[lengthFile1 - 1] != "BMP") {
			return false;
		}
	}
	return true;
}
function viewpicture(href, _width, _height){
	  _left = parseInt((window.screen.width - _width)/2);
	  _top = parseInt((window.screen.height - _height)/2);
	  features ="toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no";
	  features+=",width="+_width+",height="+_height+",left="+_left+",top="+_top;
	  window.open("../viewpicture.php?imgsrc="+escape(href),"_blank",features);
}
function isEmail(s){
	s = trim(s);
	emailPat=/^(.+)@(.+)\.(.+)$/;
	var a=s.match(emailPat);
	if (a==null){
		emailPat = /^(.+)@(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
		a=s.match(emailPat);
	}
	return (a!=null);
}
function checkImageExt(object) {
    try {
	    if (object.value != "") {
		    var valFile1 = object.value;
		    var listArrFile1 = valFile1.split(".");
		    var lengthFile1 = listArrFile1.length;
		    if (lengthFile1<=1) 
			    return false;
		    else if (listArrFile1[lengthFile1 - 1] != "gif" 
				     && listArrFile1[lengthFile1 - 1] != "GIF" 
				     && listArrFile1[lengthFile1 - 1] != "jpg" 
				     && listArrFile1[lengthFile1 - 1] != "JPG" 
				     && listArrFile1[lengthFile1 - 1] != "bmp" 
				     && listArrFile1[lengthFile1 - 1] != "BMP") {
			    return false;
		    }
	    }
    } catch (err) {return false;}
	return true;
}